83c0cfa4a973ccad0020abc68b92bcc48a4ae820,geoserver/webapp/src/main/java/com/boundlessgeo/geoserver/api/controllers/ImportController.java,ImportController,moveFile,#ImportTask#,181

Before Change


                throw new RuntimeException("Invalid store type: "+store.getClass());
            }
            
            Files.move(srcData.getFile().toPath(), destFile.toPath());
            //move any supplementary files, update ImportData
            if (srcData instanceof SpatialFile) {
                destData = new SpatialFile(destFile);

After Change


            //Test if we can actually move the file; otherwise copy the file.
            boolean move = srcFile.renameTo(srcFile);
            
            if (move) {
                Files.move(srcFile.toPath(), destFile.toPath());
            } else {
                Files.copy(srcFile.toPath(), destFile.toPath());
            }
            //move any supplementary files, update ImportData
            if (srcData instanceof SpatialFile) {
                destData = new SpatialFile(destFile);
                if (((SpatialFile)srcData).getPrjFile() != null) {
                    File prjFile = new File(destDir, ((SpatialFile)srcData).getPrjFile().getName());
                    if (move) {
                        Files.move(((SpatialFile)srcData).getPrjFile().toPath(), prjFile.toPath());
                    } else{
                        Files.copy(((SpatialFile)srcData).getPrjFile().toPath(), prjFile.toPath());
                    }
                    ((SpatialFile)destData).setPrjFile(prjFile);
                }
                for (File f : ((SpatialFile)srcData).getSuppFiles()) {
                    File suppFile = new File(destDir, f.getName());
                    if (move) {
                        Files.move(f.toPath(), suppFile.toPath());
                    } else {
                        Files.copy(f.toPath(), suppFile.toPath());
                    }
                    ((SpatialFile)destData).getSuppFiles().add(suppFile);
                }